package com.woniu.register.controller;

import com.woniu.common.util.Result;
import com.woniu.register.dto.ProposerDTO;
import com.woniu.register.service.CommonerService;
import com.woniu.register.service.ProposerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 共有人控制层
 *
 * @author 晨星
 * @date 2022/12/13 14:34
 **/
@RestController
@RequestMapping("Commoners")
public class CommonerController {
    private final CommonerService commonerService;

    public CommonerController(CommonerService commonerService) {
        this.commonerService = commonerService;
    }

    @PostMapping("/add")
    public Result add() {
        int i = commonerService.insertCommoner();
        int commonerId = commonerService.selectId();
        if (i > 0) {
            return Result.ok().data("新增共有人成功",commonerId);
        } else {
            return Result.error();
        }
    }
}
